package com.neusoft.controller;

import com.neusoft.feign.FoodFeignClient;
import com.neusoft.po.Business;
import com.neusoft.po.UserAndBusiness;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import com.neusoft.po.CommonResult;
import com.neusoft.service.BusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import java.util.ArrayList;
import java.util.List;


import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@RestController
@RequestMapping("/BusinessController")
@RefreshScope //controller开启动态更新@RefreshScope
public class BusinessController {

    @Autowired
    private BusinessService businessService;

    @GetMapping("/listBusinessByOrderTypeId")
    public CommonResult<List> listBusinessByOrderTypeId(Business business) throws Exception{
        return new CommonResult(200, "success", businessService.listBusinessByOrderTypeId(business.getOrderTypeId()));
    }

    @GetMapping("/getBusinessById")
    public CommonResult<Business> getBusinessById(Business business) throws Exception{
        return new CommonResult(200, "success", businessService.getBusinessById(business.getBusinessId()));
    }

    @GetMapping("/listBusinessByBusinessNameOrFoodName")
    public CommonResult<List> listBusinessByBusinessNameOrFoodName(Business business) throws Exception{
        return new CommonResult(200, "success", businessService.listBusinessByBusinessNameOrFoodName(business.getBusinessName()));
    }

    @GetMapping("/verifyBusinessId")
    public CommonResult<Boolean> verifyBusinessId(UserAndBusiness userAndBusiness) throws Exception{
        return new CommonResult(200, "success", businessService.verifyBusinessId(userAndBusiness));
    }

}